//
//  NewsCell.m
//  口袋
//
//  Created by dllo on 15/5/19.
//  Copyright (c) 2015年 口袋. All rights reserved.
//

#import "NewsCell.h"
#import "DKNightVersion.h"

#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 6.67
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

@implementation NewsCell

- (void)dealloc
{
    [_comments release];
    [_title release];
    [_digest release];
    [_imgsrc release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
        [DKNightVersionManager addClassToSet:self.class];
        self.backgroundColor = [UIColor whiteColor];
        self.nightBackgroundColor = UIColorFromRGB(0x343434);
    }
    return self;
}

- (void)createCell
{
    
    self.imgsrc = [[UIImageView alloc] initWithFrame:CGRectMake(HEIGHT * 0.1, HEIGHT * 0.1, HEIGHT, HEIGHT * 0.8)];
    [self.imgsrc setBackgroundColor:[UIColor colorWithRed:118/255.0 green:210/255.0 blue:245/255.0 alpha:1.0]];
    self.imgsrc.nightBackgroundColor = UIColorFromRGB(0x343434);
    [self.contentView addSubview:_imgsrc];
    [_imgsrc release];
    
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(HEIGHT + HEIGHT * 0.2, HEIGHT * 0.1, WIDTH / 4 * 3, HEIGHT / 3)];
    _title.font = [UIFont boldSystemFontOfSize:17];
    _title.nightTextColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_title];
    [_title release];
    
    self.digest = [[UILabel alloc] initWithFrame:CGRectMake(HEIGHT + HEIGHT * 0.2, HEIGHT / 7 * 3, WIDTH / 8 * 5, HEIGHT / 2)];
    _digest.numberOfLines = 0;
    _digest.textColor = [UIColor lightGrayColor];
    _digest.font = [UIFont boldSystemFontOfSize:14];
    [self.contentView addSubview:_digest];
    [_digest release];
    
    self.comments = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 10 * 7, HEIGHT / 10 * 7, WIDTH / 10 * 3 - 10, HEIGHT / 4)];
    _comments.font = [UIFont systemFontOfSize:14 weight:0.05];
    _comments.textColor = [UIColor grayColor];
    _comments.textAlignment = 2;
    [self.contentView addSubview:_comments];
    [_comments release];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
